package com.simpleservletapp.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class SimpleServlet
 */
public class SimpleServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public SimpleServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		
		out.println("<form action='ServlertForm' method='GET'>" );
		
		out.println("Username");
		out.println("<input type='text' name='userName' value=''/>");
		out.println("<input type='submit' name='submit' value='Save' />");
		out.println("</form>");
	
		
		/*String username;
		
		username = request.getParameter("name");
		
		HttpSession session = request.getSession();
		if (username!="" && username!=null) {
			session.setAttribute("SavedUserName", username);
		}
		
		out.println("Rquest Parameters has value :" +username);
		out.println("Session Parameters has value :" +(String)session.getAttribute("SavedUserName"));
	*/	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
